package com.cocostudio.erpapp;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.StringWriter;
import java.util.HashMap;
import java.util.Map;

import android.app.ProgressDialog;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.View;
import android.webkit.JavascriptInterface;
import android.webkit.JsResult;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.cocostudio.erpapp.common.Debug;
import com.cocostudio.erpapp.utils.Constant;
import com.cocostudio.erpapp.utils.WebServiceUtils;
import com.cocostudio.erpapp.vo.WSRealTimeSalesResult;
import com.cocostudio.erpapp.web.CustomWebChromeClient;
import com.cocostudio.erpapp.R;
public class RealTimePaymentsActivity extends CustomFragmentActivity {
    private static final String TAG = "RealTimePaymentsActivity";
    private static View searchView;
    
    private WebView webView;
    
    private EditText search_product_name;
    private EditText search_product_size;
    private EditText search_product_code;
    

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        if (Debug.LOGD) {
            Log.d(TAG, "onCreate.");
        }
        super.onCreate(savedInstanceState);
        initView();
        
     }
    private void initView() {
        
        setContentView(R.layout.activity_realtime_payments);
        setTitle(R.string.title_realtime_payments ); 
        setLeftButtonDrawable(R.drawable.btn_home);

        searchView = findViewById(R.id.search_component);           
        webView = (WebView) findViewById(R.id.detail_result_webview);
        webView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
        webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
        webView.getSettings().setBuiltInZoomControls(true);
        webView.getSettings().setSupportZoom(false);
        webView.setFocusableInTouchMode(true);
        webView.getSettings().setJavaScriptEnabled(true);
        webView.setWebChromeClient( new CustomWebChromeClient());

        webView.addJavascriptInterface(this, "android");
         
                
        
   }
    
//    public void onSearchClicked(View view) {
//        try {
//            pdg = ProgressDialog.show(RealTimePaymentsActivity.this, "温馨提示", "数据请求中，请稍后！");
//            pdg.setCancelable(true);
//            pdg.setCanceledOnTouchOutside(true);
//           
//            
//            webView.loadUrl( Constant.urlprefix+ "realtime_payments.html");
//            pdg.dismiss();
//
//        } catch (Exception e) {
//            // TODO Auto-generated catch block
//            e.printStackTrace();
//        }  
//    
//    }
     
    
    @Override
    protected void onStart ()
    {
        super.onStart();
        
        Handler mHandler =new Handler();
        mHandler.post( new Runnable(){
            public void run(){
                try {
                    pdg = ProgressDialog.show(RealTimePaymentsActivity.this, "温馨提示", "数据请求中，请稍后！");
                    pdg.setCancelable(true);
                    pdg.setCanceledOnTouchOutside(true);
                   
                    webView.loadUrl( Constant.urlprefix+ "realtime_payments.html");
                    pdg.dismiss();

                } catch (Exception e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }

            }

        });
        
         
        
    }
    
    @JavascriptInterface
    public String getjson() { 
        return WebServiceUtils.WS_RealtimePayments_json();
    }  
 
    @JavascriptInterface
    public String json(){
        return "helloworld";
    }
}
